package io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

/*
向文件中写入文本数据
 */
public class WriteStringDemo {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("fos.txt",true);
        String line = "如若早三五年相见,何来内心交战,我想与你继续乱缠,难再有发展,但我想跟你乱缠";
        byte[] data = line.getBytes(StandardCharsets.UTF_8);//将字符串转为字节码文件
        fos.write(data);
        fos.write(",惊天动地只可惜天地亦无情,不敢有风,不敢有声,这爱情无人证,飞天遁地贪一刻的乐极忘形,好想说谎,不眨眼睛,这爱情无人性".getBytes(StandardCharsets.UTF_8));
        System.out.println("写出完毕");
        fos.close();
    }
}
